
package org.vectrics.history;


import org.apache.log4j.Logger;
import org.vectrics.NoProviderException;
import org.vectrics.user.Person;
import org.vectrics.user.ServiceRequest;
import org.vectrics.user.ServiceRequestCriteria;
import org.vectrics.user.ServiceRequestSortOrder;

import java.util.Date;
import java.util.Collection;
import java.util.List;

abstract public class HistoryProvider {
	static private transient Logger log = Logger.getLogger(HistoryProvider.class);
	private static HistoryProvider instance = null;
	
	public HistoryProvider() {
		super();
		instance = this;
	}

	static public HistoryProvider getInstance() throws NoProviderException{
		if (instance == null) {
			log.error("A history provider was not instantiated");
			throw new NoProviderException("A history provider was not instantiated");
		}
		return(instance);
	}

	abstract public Activity createHistory(String objectType, String objectId, 
	        String activityTypeCode, Person person, String description);
	abstract public Collection findObjectHistoryEntries(String objectType, String objectId);
	abstract public Collection findHistoryEntriesBy(Person person);
	abstract public Collection findHistoryEntries(Date startDate, Date endDate);
	abstract public void clearObjectHistory(String objectType, String objectId);
	abstract public void saveServiceRequest(ServiceRequest serviceRequest);
	abstract public List findServiceRequests(
			ServiceRequestCriteria criteria, ServiceRequestSortOrder sort, int start, int end);
	abstract public int findServiceRequestsCount(
			ServiceRequestCriteria criteria, int start, int end);
}
